package com.etc.register.service;

import com.etc.register.entity.Contact;
import com.etc.register.repository.ContactRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ContactService
 * @Description 紧急联系人表的业务层
 * @Author 聪
 * @Date 2019/8/9 15:41
 * @Version 1.0
 */
@Service
public class ContactService {
    @Autowired
    private ContactRepository contactRepository;


    /**
     * 查询全部
     *
     * @return
     */
    public List<Contact> findByAll() {
        List<Contact> all = contactRepository.findAll();
        return all;
    }

    /**
     * 添加
     *
     * @param contact
     * @return
     */
    public Contact save(Contact contact) {

        return contactRepository.save(contact);
    }

    /**
     * 根据id删除
     *
     * @param tid
     * @return
     */
    public Integer deleteById(Integer tid) {
        Integer result = null;
        try {
            result = 1;
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

}

